package Thread;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class demo5 {
    public ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        // write code here
        ArrayList<Integer> list = new ArrayList<>();
        int m = nums1.size();
        int n = nums2.size();
        int[] hash = new int[1000];
        for(int i = 0;i < n;i++) {
            if(nums2.contains(nums1.get(i))) {
                hash[nums1.get(i)]++;
            }
            if(hash[nums1.get(i)] > 1) {
                continue;
            }
        }
        for(int i = 0;i < 1000;i++) {
            if(hash[nums1.get(i)] > 1) list.add(hash[nums1.get(i)]);
        }
        return list;
    }
    public static void main(String[] args)  {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();
            Stack<Character> stack = new Stack<>();
            for(int i = 0;i < s.length();i++) {
                char c = s.charAt(i);
                if(stack.peek() != c || stack.isEmpty()) stack.push(c);
                else if(stack.peek() == c) stack.pop();
            }
            Stack<Character> s2 = new Stack<>();
            if(stack.isEmpty()) System.out.println(0);
            else {
                while (!stack.isEmpty()) {
                    s2.push(s2.pop());
                }
                while(!s2.isEmpty()) {
                    System.out.print(s2.pop());
                }
            }
        }

    }
}

